package demo1229.lining;

public class Customer extends Thread {


    Bun bun;

    public Customer(Bun bun) {
        this.bun = bun;
    }

    @Override
    public void run() {
        while (true){
            synchronized (bun){
                if (!bun.isEmpty()){

                    try {
                        bun.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                }

                System.out.println("顾客开始吃"+bun.getPi()+bun.getXian()+"包子");
                System.out.println("======================");
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                bun.setEmpty(false);
                bun.notify();

            }




        }






    }
}
